package lt.mii.optimum.opt;

import java.util.Iterator;

import lt.mii.optimum.components.Lesson;
import lt.mii.optimum.components.Student;

public class Switching {

	void switchLessons(Lesson l1, Lesson l2) {
		if (canSwitchTeachers(l1, l2)) {
			if (canSwitchStrudents(l1, l2)) {

			}
		}

	}



	boolean canSwitchTeachers(Lesson l1, Lesson l2) {
		return l1.getTeacher().isBusy(l2.getFlow())
				&& l2.getTeacher().isBusy(l1.getFlow());
	}



	void switchTeachers(Lesson l1, Lesson l2) {

	}



	boolean canSwitchStrudents(Lesson l1, Lesson l2) {

		Iterator<Student> it = l1.getStudents().iterator();

		while (it.hasNext()) {
			if (it.next().isBusy(l2))
				return false;
		}

		it = l2.getStudents().iterator();

		while (it.hasNext()) {
			if (it.next().isBusy(l1))
				return false;
		}

		return true;
	}



	void switchStudents(Lesson l1, Lesson l2) {

	}
}
